// Copyright (c) 2022 Presto Labs Pte. Ltd.
// Author: leon

#pragma once

#include <map>
#include <memory>
#include <string>
#include <vector>

#include <rapidjson/document.h>

// internal
#include "coin2/exchange/base/feed/processor.h"
#include "coin2/exchange/base/market/enums.h"
#include "coin2/exchange/di/constant.h"

namespace coin2::exchange::mexc_futures::feed_v1 {
namespace impl {
using coin2::exchange::base::executor::TopicRecordPacket;
using namespace coin2::exchange::base::symbology;
class MexcFuturesFeedProcessor : public base::feed::FeedParsingProcessor {
 public:
  explicit MexcFuturesFeedProcessor(
      const std::string& system_name,
      const coin2::exchange::di::ConstantInjection& ci,
      const feed::RawParserConfig& config,
      const MarketExchangeApi& mea)
      : FeedParsingProcessor(
            system_name,
            mea,
            ci,
            config,
            "cc/coin2/exchange/mexc/feed_v2/schema.json") {}
  void OnTopicRecord(const base::executor::TopicRecordPacket& packet) override;
  std::string ExtractChannel(const rapidjson::Document& doc) {
    if (!doc.HasMember("channel")) {
      return "unknown";
    }
    const std::string& channel = doc["channel"].GetString();
    if (channel == "push.depth") {
      return "depth";
    } else if (channel == "push.depth.full") {
      return "book_full";
    } else if (channel == "push.deal") {
      return "trade";
    } else if (channel == "push.index.price") {
      return "index";
    } else if (channel == "push.fair.price") {
      return "mark_price";
    } else if (channel == "push.funding.rate") {
      return "funding_rate";
    } else {
      return "unknown";
    }
  }
};
}  // namespace impl
using impl::MexcFuturesFeedProcessor;
}  // namespace coin2::exchange::mexc_futures::feed_v1
